//package com.huanletao.word;
//
//import com.spire.doc.Document;
//import com.spire.doc.FileFormat;
//import org.apache.poi.openxml4j.opc.OPCPackage;
//import org.apache.poi.xwpf.usermodel.XWPFDocument;
//import org.apache.poi.xwpf.usermodel.XWPFParagraph;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.*;
//import java.util.List;
//
//public class WordToOFD {
//
//    private static Logger log = LoggerFactory.getLogger(WordToOFD.class);
//
//    public static void main(String[] args) throws IOException {
//        //实例化Document类的对象
//        Document document = new Document();
//
//        //加载Word文档
////        document.loadFromFile("E:\\tmp\\003\\超限运输车辆通行证(1).docx");
//        document.loadFromFile("E:\\tmp\\003\\超限运输车辆通行证.docx");
//
//        //保存为OFD格式
//        document.saveToFile("E:\\tmp\\003\\超限运输车辆通行证02.ofd", FileFormat.OFD);
//        log.info("转换完成{}","E:\\tmp\\003\\超限运输车辆通行证02.ofd");
////        restWord("E:\\tmp\\003\\超限运输车辆通行证4.ofd");
//
//    }
//
//    public static void cleanLicenseFlag(File file) {
//        try {
//            XWPFDocument doc = new XWPFDocument(new FileInputStream(file.getPath()));
//            doc.removeBodyElement(0);
//            doc.write(new FileOutputStream(file.getPath()));
//            doc.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    /**
//     * 使用spire.Doc 会出现一个水印可以通过这个方法去除水印
//     * @param docFilePath
//     */
//    public static void restWord(String docFilePath) {
//        try (FileInputStream in = new FileInputStream(docFilePath)) {
//            XWPFDocument doc = new XWPFDocument(OPCPackage.open(in));
//            List<XWPFParagraph> paragraphs = doc.getParagraphs();
//            if (paragraphs.size() < 1) {
//                return;
//            }
//            XWPFParagraph firstParagraph = paragraphs.get(0);
//            if (firstParagraph.getText().contains("Spire.Doc")) {
//                doc.removeBodyElement(doc.getPosOfParagraph(firstParagraph));
//            }
//            OutputStream out = new FileOutputStream(docFilePath);
//            doc.write(out);
//            out.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//
//}